const router = require("koa-router")();
router.prefix("/user");

router.get("/list", async (ctx) => {
  console.log("查询参数", ctx.query);
  const list = [
    { name: "黎**1", age: 1 },
    { name: "黎**2", age: 2 },
    { name: "黎**3", age: 3 },
    { name: "黎**4", age: 4 },
    { name: "黎**5", age: 5 },
  ];
  await asyncOpt()
  ctx.body = {
    data: list,
    status:0,
    msg:'成功'
  };
 
});
function asyncOpt() {
  return new Promise(r => setTimeout(()=> r(), 600))
} 
  
router.get("/:id", async (ctx) => {
  const { id } = ctx.params;
  const info ={
      name:`黎**${id}`,
      age:id,
      addr:'广州市天河区',
      admin:'manger'
  }
  ctx.body =  ctx.body = {
    data: info,
    status:0,
    msg:'成功'
  };
});
module.exports = router.routes();
